import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-12
 * Time: 15:26
 */
public class Test_0812 {

    public static int countSegments(String s) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if ((i == 0 || s.charAt(i - 1) == ' ') && s.charAt(i) != ' ') {
                count++;
            }
        }
        return count;
    }

    public static void main1(String[] args) {
        String str = " Hellow word bit";
        int ret = countSegments(str);

        String[] str1 = str.split(" ");
        System.out.println(Arrays.toString(str1));
        for (int i = 0; i < str.length(); i++) {
            System.out.println(str.charAt(i));
        }
    }

    public static String toLowerCase(String s) {
        StringBuilder a = new StringBuilder();
        for(int i = 0; i<s.length(); i++){
            char ch = s.charAt(i);
            if(ch<='Z'&&ch>='A'){
                ch|=32;
            }
            a.append(ch);
        }
        return a.toString();
    }

    //1.大写变小写、小写变大写 : 字符 ^= 32  --  小变大
    //  只能原本小写字符变大写字符 或者原本大写变小写

    //2.大写变小写、小写变小写 : 字符 |= 32  --  大变小
    //  原本大写字符变小写字符

    //3.小写变大写、大写变大写 : 字符 &= -33

    public static void main2(String[] args) {
        //字符转换
        String str = "alow abc";
        String str1 = "ABCDEF";
        System.out.println(toLowerCase(str1));
        //System.out.println(toLowerCase(str));
    }

}
